<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户中心 - 华为全球商店</title>
    <style>
        /* 基础样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
            background: #f8fafc;
            color: #1f2937;
            line-height: 1.6;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }
        
        /* 禁用按钮样式 */
        .disabled-btn {
            background-color: #ccc !important;
            color: #666 !important;
            cursor: not-allowed !important;
            border-color: #d1d5db !important;
            pointer-events: none; /* 禁止点击事件 */
        }
        
        /* 按钮样式 */
        .btn {
            padding: 10px 20px;
            border-radius: 8px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            border: none;
            text-decoration: none;
            display: inline-block;
            text-align: center;
        }
        
        .btn-primary {
            background: linear-gradient(135deg, #3b82f6, #1d4ed8);
            color: white;
        }
        
        .btn-primary:hover {
            background: linear-gradient(135deg, #1d4ed8, #1e40af);
            transform: translateY(-2px);
        }
        
        .btn-outline {
            background: transparent;
            border: 2px solid #3b82f6;
            color: #3b82f6;
        }
        
        .btn-outline:hover {
            background: #3b82f6;
            color: white;
        }
        
        .btn-secondary {
            background: #f3f4f6;
            color: #374151;
        }
        
        .btn-secondary:hover {
            background: #e5e7eb;
        }
        
        .btn-danger {
            background: #ef4444;
            color: white;
        }
        
        .btn-danger:hover {
            background: #dc2626;
        }
        
        .btn-small {
            padding: 6px 12px;
            font-size: 14px;
        }
        
        /* 头部样式 */
        .header {
            background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
            color: white;
            padding: 15px 0;
            position: sticky;
            top: 0;
            z-index: 1000;
            box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        }
        
        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .logo {
            font-size: 26px;
            font-weight: bold;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .nav {
            display: flex;
            gap: 25px;
        }
        
        .nav a {
            color: white;
            text-decoration: none;
            font-weight: 500;
            padding: 8px 15px;
            border-radius: 8px;
            transition: all 0.3s ease;
        }
        
        .nav a:hover {
            background: rgba(255,255,255,0.2);
        }
        
        .user-actions {
            display: flex;
            gap: 15px;
            align-items: center;
        }
        
        .cart-icon {
            position: relative;
            cursor: pointer;
            font-size: 24px;
            padding: 8px;
            border-radius: 50%;
            transition: all 0.3s ease;
        }
        
        .cart-icon:hover {
            background: rgba(255,255,255,0.2);
        }
        
        .cart-count {
            position: absolute;
            top: -5px;
            right: -5px;
            background: #ef4444;
            color: white;
            font-size: 12px;
            padding: 2px 6px;
            border-radius: 50%;
            min-width: 18px;
            text-align: center;
        }
        
        /* 面包屑导航 */
        .breadcrumb {
            background: #fff;
            padding: 15px 0;
            border-bottom: 1px solid #e5e7eb;
        }
        
        .breadcrumb-list {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 14px;
        }
        
        .breadcrumb-list a {
            color: #6b7280;
            text-decoration: none;
        }
        
        .breadcrumb-list a:hover {
            color: #3b82f6;
        }
        
        .breadcrumb-separator {
            color: #9ca3af;
        }
        
        /* 用户中心样式 */
        .user-center {
            padding: 50px 0;
        }
        
        .user-center-container {
            display: grid;
            grid-template-columns: 280px 1fr;
            gap: 30px;
        }
        
        /* 用户侧边栏 */
        .user-sidebar {
            background: #fff;
            border-radius: 16px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.05);
            overflow: hidden;
        }
        
        .user-profile {
            padding: 30px 20px;
            text-align: center;
            border-bottom: 1px solid #f3f4f6;
        }
        
        .user-avatar {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background: linear-gradient(135deg, #3b82f6, #1d4ed8);
            color: white;
            font-size: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 15px;
            position: relative;
        }
        
        .avatar-upload {
            position: absolute;
            bottom: 0;
            right: 0;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background: white;
            color: #3b82f6;
            font-size: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        .user-name {
            font-size: 20px;
            font-weight: 600;
            margin-bottom: 5px;
        }
        
        .user-level {
            color: #6b7280;
            font-size: 14px;
            margin-bottom: 20px;
        }
        
        .user-stats {
            display: flex;
            justify-content: center;
            gap: 20px;
        }
        
        .stat-item {
            text-align: center;
        }
        
        .stat-number {
            font-weight: 600;
            color: #3b82f6;
        }
        
        .stat-label {
            font-size: 12px;
            color: #6b7280;
        }
        
        .user-menu {
            list-style: none;
        }
        
        .user-menu li {
            border-bottom: 1px solid #f3f4f6;
        }
        
        .user-menu a {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 15px 20px;
            color: #374151;
            text-decoration: none;
            transition: all 0.3s ease;
        }
        
        .user-menu a:hover,
        .user-menu a.active {
            background: #f1f5f9;
            color: #3b82f6;
        }
        
        .menu-icon {
            width: 24px;
            text-align: center;
        }
        
        .menu-badge {
            margin-left: auto;
            background: #ef4444;
            color: white;
            font-size: 12px;
            padding: 2px 8px;
            border-radius: 10px;
        }
        
        /* 用户内容区 */
        .user-content {
            background: #fff;
            border-radius: 16px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.05);
            overflow: hidden;
        }
        
        .content-header {
            padding: 25px 30px;
            border-bottom: 1px solid #f3f4f6;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .content-title {
            font-size: 22px;
            font-weight: 600;
        }
        
        .content-body {
            padding: 30px;
        }
        
        /* 控制台样式 */
        .dashboard-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .dashboard-card {
            background: #f8fafc;
            border-radius: 12px;
            padding: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .dashboard-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.05);
        }
        
        .card-icon {
            font-size: 32px;
            margin-bottom: 15px;
            color: #3b82f6;
        }
        
        .card-title {
            font-weight: 600;
            margin-bottom: 5px;
        }
        
        .card-desc {
            color: #6b7280;
            font-size: 14px;
            margin-bottom: 15px;
        }
        
        .card-action {
            color: #3b82f6;
            font-weight: 500;
            font-size: 14px;
        }
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
        }
        
        .stat-card {
            background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
            color: white;
            border-radius: 12px;
            padding: 20px;
        }
        
        .stat-value {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 5px;
        }
        
        .stat-title {
            opacity: 0.9;
            margin-bottom: 10px;
        }
        
        .stat-change {
            font-size: 14px;
            opacity: 0.8;
        }
        
        /* 订单样式 */
        .order-filters {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }
        
        .filter-btn {
            padding: 8px 16px;
            background: #f3f4f6;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .filter-btn.active {
            background: #3b82f6;
            color: white;
        }
        
        .order-list {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        
        .order-item {
            border: 1px solid #f3f4f6;
            border-radius: 12px;
            overflow: hidden;
            transition: all 0.3s ease;
        }
        
        .order-item:hover {
            box-shadow: 0 5px 15px rgba(0,0,0,0.05);
        }
        
        .order-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 20px;
            background: #f8fafc;
            border-bottom: 1px solid #f3f4f6;
        }
        
        .order-date {
            color: #6b7280;
            font-size: 14px;
        }
        
        .order-status {
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 14px;
            font-weight: 500;
        }
        
        .status-processing {
            background: #fef3c7;
            color: #d97706;
        }
        
        .status-shipped {
            background: #dbeafe;
            color: #1e40af;
        }
        
        .status-delivered {
            background: #dcfce7;
            color: #059669;
        }
        
        .status-cancelled {
            background: #fee2e2;
            color: #dc2626;
        }
        
        .order-products {
            padding: 15px 20px;
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .product-image {
            width: 60px;
            height: 60px;
            background: #f1f5f9;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
        }
        
        .product-specs {
            color: #6b7280;
            font-size: 14px;
        }
        
        .order-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 20px;
            background: #f8fafc;
            border-top: 1px solid #f3f4f6;
        }
        
        .order-total {
            font-weight: 600;
        }
        
        .order-actions {
            display: flex;
            gap: 10px;
        }
        
        /* 地址样式 */
        .address-list {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        
        .address-card {
            border: 1px solid #f3f4f6;
            border-radius: 12px;
            padding: 20px;
            position: relative;
        }
        
        .address-card.default {
            border-color: #3b82f6;
        }
        
        .default-badge {
            position: absolute;
            top: 20px;
            right: 20px;
            background: #3b82f6;
            color: white;
            font-size: 12px;
            padding: 2px 8px;
            border-radius: 4px;
        }
        
        .address-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
        }
        
        .address-phone {
            color: #6b7280;
            font-size: 14px;
        }
        
        .address-details {
            margin-bottom: 15px;
            color: #4b5563;
        }
        
        .address-actions {
            display: flex;
            gap: 10px;
        }
        
        /* 表单样式 */
        .profile-form {
            max-width: 600px;
        }
        
        .form-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-bottom: 20px;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
        }
        
        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
            padding: 12px;
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            font-size: 16px;
        }
        
        .form-group textarea {
            resize: vertical;
        }
        
        /* 设置样式 */
        .settings-section {
            margin-bottom: 30px;
        }
        
        .settings-title {
            font-size: 18px;
            margin-bottom: 15px;
            color: #1f2937;
        }
        
        .setting-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 0;
            border-bottom: 1px solid #f3f4f6;
        }
        
        .setting-info {
            flex: 1;
        }
        
        .setting-name {
            font-weight: 500;
            margin-bottom: 3px;
        }
        
        .setting-desc {
            color: #6b7280;
            font-size: 14px;
        }
        
        .toggle-switch {
            width: 50px;
            height: 26px;
            background: #e5e7eb;
            border-radius: 13px;
            position: relative;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .toggle-switch::after {
            content: '';
            position: absolute;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            top: 2px;
            left: 2px;
            background: white;
            transition: all 0.3s ease;
        }
        
        .toggle-switch.active {
            background: #3b82f6;
        }
        
        .toggle-switch.active::after {
            left: 26px;
        }
        
        /* 动画 */
        .fade-in {
            animation: fadeIn 0.6s ease-in-out;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        /* 响应式设计 */
        @media (max-width: 768px) {
            .user-center-container {
                grid-template-columns: 1fr;
            }
            
            .form-row {
                grid-template-columns: 1fr;
            }
            
            .nav {
                display: none;
            }
            
            .dashboard-cards,
            .stats-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <!-- Header -->
    <header class="header">
        <div class="container">
            <div class="header-content">
                <div class="logo" onclick="window.location.href='index.html'">
                    🏪 HUAWEI Global Store
                </div>
                <nav class="nav">
                    <a href="index.html">首页</a>
                    <a href="product-list.html">新品</a>
                    <a href="support.html">支持</a>
                    <a href="about.html">关于</a>
                </nav>
                <div class="user-actions">
                    <select style="padding: 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); color: white;">
                        <option>🇨🇳 中文</option>
                        <option>🇺🇸 English</option>
                        <option>🇯🇵 日本語</option>
                        <option>🇩🇪 Deutsch</option>
                    </select>
                    <div class="cart-icon" id="cartIcon">
                        🛒
                        <div class="cart-count" id="cartCount">0</div>
                    </div>
                    <!-- 登录按钮 -->
                    <button id="loginBtn" 
                        class="btn btn-outline" 
                        style="padding: 8px 16px; background: transparent; border: 2px solid white; color: white;" 
                        onclick="openLoginModal()">登录</button>

                    <!-- 个人中心按钮 -->
                    <button id="profileBtn" 
                        class="btn btn-outline" 
                        style="padding: 8px 16px; background: transparent; border: 2px solid white; color: white;" 
                        onclick="handleProfileClick()">个人中心</button>
                </div>
            </div>
        </div>
    </header>

    <!-- Breadcrumb -->
    <nav class="breadcrumb">
        <div class="container">
            <div class="breadcrumb-list">
                <a href="index.html">首页</a>
                <span class="breadcrumb-separator">></span>
                <span>用户中心</span>
            </div>
        </div>
    </nav>

    <!-- User Center -->
    <section class="user-center">
        <div class="container">
            <div class="user-center-container">
                <!-- User Sidebar -->
                <div class="user-sidebar fade-in">
                    <div class="user-profile">
                        <div class="user-avatar">
                            👤
                            <div class="avatar-upload" title="更换头像">📷</div>
                        </div>
                        <div class="user-name">张三</div>
                        <div class="user-level">VIP黄金会员</div>
                        <div class="user-stats">
                            <div class="stat-item">
                                <div class="stat-number">15</div>
                                <div class="stat-label">订单数</div>
                            </div>
                            <div class="stat-item">
                                <div class="stat-number">2,847</div>
                                <div class="stat-label">积分</div>
                            </div>
                            <div class="stat-item">
                                <div class="stat-number">3</div>
                                <div class="stat-label">优惠券</div>
                            </div>
                        </div>
                    </div>
                    
                    <ul class="user-menu">
                        <li><a href="#" onclick="showContent('dashboard')" class="active">
                            <span class="menu-icon">🏠</span>
                            <span>控制台</span>
                        </a></li>
                        <li><a href="#" onclick="showContent('orders')">
                            <span class="menu-icon">📦</span>
                            <span>我的订单</span>
                            <span class="menu-badge">2</span>
                        </a></li>
                        <li><a href="#" onclick="showContent('addresses')">
                            <span class="menu-icon">📍</span>
                            <span>收货地址</span>
                        </a></li>
                        <li><a href="#" onclick="showContent('profile')">
                            <span class="menu-icon">👤</span>
                            <span>个人资料</span>
                        </a></li>
                        <li><a href="#" onclick="showContent('security')">
                            <span class="menu-icon">🔒</span>
                            <span>安全设置</span>
                        </a></li>
                        <li><a href="#" onclick="showContent('notifications')">
                            <span class="menu-icon">🔔</span>
                            <span>消息通知</span>
                            <span class="menu-badge">5</span>
                        </a></li>
                        <li><a href="#" onclick="showContent('coupons')">
                            <span class="menu-icon">🎫</span>
                            <span>优惠券</span>
                        </a></li>
                        <li><a href="#" onclick="showContent('points')">
                            <span class="menu-icon">⭐</span>
                            <span>积分中心</span>
                        </a></li>
                        <li><a href="#" onclick="showContent('settings')">
                            <span class="menu-icon">⚙️</span>
                            <span>系统设置</span>
                        </a></li>
                        <li><a href="#" onclick="logout()">
                            <span class="menu-icon">🚪</span>
                            <span>退出登录</span>
                        </a></li>
                    </ul>
                </div>

                <!-- User Content -->
                <div class="user-content fade-in">
                    <!-- Dashboard -->
                    <div id="dashboard" class="content-section">
                        <div class="content-header">
                            <h2 class="content-title">控制台</h2>
                        </div>
                        <div class="content-body">
                            <div class="dashboard-cards">
                                <div class="dashboard-card" onclick="showContent('orders')">
                                    <div class="card-icon">📦</div>
                                    <div class="card-title">我的订单</div>
                                    <div class="card-desc">查看和管理您的所有订单</div>
                                    <div class="card-action">查看详情 →</div>
                                </div>
                                <div class="dashboard-card" onclick="showContent('addresses')">
                                    <div class="card-icon">📍</div>
                                    <div class="card-title">收货地址</div>
                                    <div class="card-desc">管理您的收货地址信息</div>
                                    <div class="card-action">管理地址 →</div>
                                </div>
                                <div class="dashboard-card" onclick="showContent('coupons')">
                                    <div class="card-icon">🎫</div>
                                    <div class="card-title">优惠券</div>
                                    <div class="card-desc">查看可用和已使用的优惠券</div>
                                    <div class="card-action">查看优惠券 →</div>
                                </div>
                                <div class="dashboard-card" onclick="showContent('points')">
                                    <div class="card-icon">⭐</div>
                                    <div class="card-title">积分中心</div>
                                    <div class="card-desc">查看积分余额和兑换记录</div>
                                    <div class="card-action">积分商城 →</div>
                                </div>
                            </div>

                            <div class="stats-grid">
                                <div class="stat-card">
                                    <div class="stat-value">¥12,876</div>
                                    <div class="stat-title">累计消费</div>
                                    <div class="stat-change">↗ 比上月增长 8.2%</div>
                                </div>
                                <div class="stat-card" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
                                    <div class="stat-value">15</div>
                                    <div class="stat-title">订单总数</div>
                                    <div class="stat-change">✅ 全部完成配送</div>
                                </div>
                                <div class="stat-card" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
                                    <div class="stat-value">98%</div>
                                    <div class="stat-title">满意度</div>
                                    <div class="stat-change">⭐ 超过平均水平</div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Orders -->
                    <div id="orders" class="content-section" style="display: none;">
                        <div class="content-header">
                            <h2 class="content-title">我的订单</h2>
                        </div>
                        <div class="content-body">
                            <div class="order-filters">
                                <button class="filter-btn active" onclick="filterOrders('all')">全部</button>
                                <button class="filter-btn" onclick="filterOrders('processing')">处理中</button>
                                <button class="filter-btn" onclick="filterOrders('shipped')">已发货</button>
                                <button class="filter-btn" onclick="filterOrders('delivered')">已完成</button>
                                <button class="filter-btn" onclick="filterOrders('cancelled')">已取消</button>
                            </div>

                            <div class="order-list">
                                <div class="order-item" data-status="delivered">
                                    <div class="order-header">
                                        <div class="order-info">
                                            <h4>订单号：HW20241210001</h4>
                                            <div class="order-date">2024-12-10 14:30:25</div>
                                        </div>
                                        <div class="order-status status-delivered">已完成</div>
                                    </div>
                                    <div class="order-products">
                                        <div class="product-image">📱</div>
                                        <div class="product-details">
                                            <div class="product-name">华为Mate 70 Pro</div>
                                            <div class="product-specs">512GB · 雅黑 × 1</div>
                                        </div>
                                    </div>
                                    <div class="order-footer">
                                        <div class="order-total">总计: ¥7,599</div>
                                        <div class="order-actions">
                                            <button class="btn btn-outline btn-small">查看详情</button>
                                            <button class="btn btn-outline btn-small">再次购买</button>
                                            <button class="btn btn-outline btn-small">申请售后</button>
                                        </div>
                                    </div>
                                </div>

                                <div class="order-item" data-status="shipped">
                                    <div class="order-header">
                                        <div class="order-info">
                                            <h4>订单号：HW20241208002</h4>
                                            <div class="order-date">2024-12-08 09:15:42</div>
                                        </div>
                                        <div class="order-status status-shipped">运输中</div>
                                    </div>
                                    <div class="order-products">
                                        <div class="product-image">⌚</div>
                                        <div class="product-details">
                                            <div class="product-name">华为WATCH GT 5</div>
                                            <div class="product-specs">46mm · 星河银 × 1</div>
                                        </div>
                                    </div>
                                    <div class="order-footer">
                                        <div class="order-total">总计: ¥2,199</div>
                                        <div class="order-actions">
                                            <button class="btn btn-primary btn-small">查看物流</button>
                                            <button class="btn btn-outline btn-small">联系客服</button>
                                        </div>
                                    </div>
                                </div>

                                <div class="order-item" data-status="processing">
                                    <div class="order-header">
                                        <div class="order-info">
                                            <h4>订单号：HW20241205003</h4>
                                            <div class="order-date">2024-12-05 16:22:18</div>
                                        </div>
                                        <div class="order-status status-processing">处理中</div>
                                    </div>
                                    <div class="order-products">
                                        <div class="product-image">🎧</div>
                                        <div class="product-details">
                                            <div class="product-name">华为FreeBuds Pro 4</div>
                                            <div class="product-specs">陶瓷白 × 1</div>
                                        </div>
                                    </div>
                                    <div class="order-footer">
                                        <div class="order-total">总计: ¥1,399</div>
                                        <div class="order-actions">
                                            <button class="btn btn-danger btn-small">取消订单</button>
                                            <button class="btn btn-outline btn-small">修改地址</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Addresses -->
                    <div id="addresses" class="content-section" style="display: none;">
                        <div class="content-header">
                            <h2 class="content-title">收货地址</h2>
                            <button class="btn btn-primary" onclick="addAddress()">+ 添加地址</button>
                        </div>
                        <div class="content-body">
                            <div class="address-list">
                                <div class="address-card default">
                                    <div class="default-badge">默认地址</div>
                                    <div class="address-header">
                                        <div>
                                            <div class="address-name">张三</div>
                                            <div class="address-phone">138****8888</div>
                                        </div>
                                    </div>
                                    <div class="address-details">
                                        广东省深圳市南山区科技园南区深南大道10000号腾讯大厦A座1101室
                                    </div>
                                    <div class="address-actions">
                                        <button class="btn btn-outline btn-small">编辑</button>
                                        <button class="btn btn-secondary btn-small">删除</button>
                                    </div>
                                </div>

                                <div class="address-card">
                                    <div class="address-header">
                                        <div>
                                            <div class="address-name">李四</div>
                                            <div class="address-phone">139****9999</div>
                                        </div>
                                    </div>
                                    <div class="address-details">
                                        北京市海淀区中关村大街1号中关村广场A座2001室
                                    </div>
                                    <div class="address-actions">
                                        <button class="btn btn-primary btn-small">设为默认</button>
                                        <button class="btn btn-outline btn-small">编辑</button>
                                        <button class="btn btn-secondary btn-small">删除</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Profile -->
                    <div id="profile" class="content-section" style="display: none;">
                        <div class="content-header">
                            <h2 class="content-title">个人资料</h2>
                        </div>
                        <div class="content-body">
                            <form class="profile-form">
                                <div class="form-row">
                                    <div class="form-group">
                                        <label>姓名</label>
                                        <input type="text" value="张三" placeholder="请输入真实姓名">
                                    </div>
                                    <div class="form-group">
                                        <label>性别</label>
                                        <select>
                                            <option>男</option>
                                            <option>女</option>
                                            <option>不便透露</option>
                                        </select>
                                    </div>
                                </div>
                                
                                <div class="form-row">
                                    <div class="form-group">
                                        <label>手机号码</label>
                                        <input type="tel" value="138****8888" placeholder="请输入手机号码">
                                    </div>
                                    <div class="form-group">
                                        <label>电子邮箱</label>
                                        <input type="email" value="zhang****@email.com" placeholder="请输入电子邮箱">
                                    </div>
                                </div>
                                
                                <div class="form-row">
                                    <div class="form-group">
                                        <label>出生日期</label>
                                        <input type="date" value="1990-01-01">
                                    </div>
                                    <div class="form-group">
                                        <label>所在地区</label>
                                        <select>
                                            <option>广东省深圳市</option>
                                            <option>北京市</option>
                                            <option>上海市</option>
                                            <option>其他</option>
                                        </select>
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <label>个人简介</label>
                                    <textarea rows="4" placeholder="介绍一下自己吧..."></textarea>
                                </div>
                                
                                <div style="margin-top: 30px;">
                                    <button type="button" class="btn btn-primary" onclick="saveProfile()">保存修改</button>
                                    <button type="button" class="btn btn-outline" style="margin-left: 15px;">取消</button>
                                </div>
                            </form>
                        </div>
                    </div>

                    <!-- Security -->
                    <div id="security" class="content-section" style="display: none;">
                        <div class="content-header">
                            <h2 class="content-title">安全设置</h2>
                        </div>
                        <div class="content-body">
                            <div class="settings-section">
                                <h3 class="settings-title">登录密码</h3>
                                <div class="setting-item">
                                    <div class="setting-info">
                                        <div class="setting-name">密码</div>
                                        <div class="setting-desc">定期更新密码有助于账户安全</div>
                                    </div>
                                    <button class="btn btn-outline btn-small">修改密码</button>
                                </div>
                            </div>

                            <div class="settings-section">
                                <h3 class="settings-title">双重认证</h3>
                                <div class="setting-item">
                                    <div class="setting-info">
                                        <div class="setting-name">手机短信验证</div>
                                        <div class="setting-desc">已绑定手机 138****8888</div>
                                    </div>
                                    <div class="toggle-switch active" onclick="toggleSetting(this)"></div>
                                </div>
                                <div class="setting-item">
                                    <div class="setting-info">
                                        <div class="setting-name">邮箱验证</div>
                                        <div class="setting-desc">已绑定邮箱 zhang****@email.com</div>
                                    </div>
                                    <div class="toggle-switch" onclick="toggleSetting(this)"></div>
                                </div>
                            </div>

                            <div class="settings-section">
                                <h3 class="settings-title">登录记录</h3>
                                <div class="setting-item">
                                    <div class="setting-info">
                                        <div class="setting-name">最近登录</div>
                                        <div class="setting-desc">2024-12-14 10:30:25 深圳市</div>
                                    </div>
                                    <button class="btn btn-outline btn-small">查看详情</button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Settings -->
                    <div id="settings" class="content-section" style="display: none;">
                        <div class="content-header">
                            <h2 class="content-title">系统设置</h2>
                        </div>
                        <div class="content-body">
                            <div class="settings-section">
                                <h3 class="settings-title">通知设置</h3>
                                <div class="setting-item">
                                    <div class="setting-info">
                                        <div class="setting-name">订单状态通知</div>
                                        <div class="setting-desc">订单状态变更时发送通知</div>
                                    </div>
                                    <div class="toggle-switch active" onclick="toggleSetting(this)"></div>
                                </div>
                                <div class="setting-item">
                                    <div class="setting-info">
                                        <div class="setting-name">促销活动通知</div>
                                        <div class="setting-desc">新品发布和促销活动推送</div>
                                    </div>
                                    <div class="toggle-switch active" onclick="toggleSetting(this)"></div>
                                </div>
                                <div class="setting-item">
                                    <div class="setting-info">
                                        <div class="setting-name">系统维护通知</div>
                                        <div class="setting-desc">系统维护和更新通知</div>
                                    </div>
                                    <div class="toggle-switch" onclick="toggleSetting(this)"></div>
                                </div>
                            </div>

                            <div class="settings-section">
                                <h3 class="settings-title">隐私设置</h3>
                                <div class="setting-item">
                                    <div class="setting-info">
                                        <div class="setting-name">个性化推荐</div>
                                        <div class="setting-desc">根据您的浏览记录推荐商品</div>
                                    </div>
                                    <div class="toggle-switch active" onclick="toggleSetting(this)"></div>
                                </div>
                                <div class="setting-item">
                                    <div class="setting-info">
                                        <div class="setting-name">数据分析</div>
                                        <div class="setting-desc">帮助我们改进产品和服务</div>
                                    </div>
                                    <div class="toggle-switch active" onclick="toggleSetting(this)"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <script>
        // 显示/隐藏内容区域的函数
        function showContent(contentId) {
            // 隐藏所有内容区域
            document.querySelectorAll('.content-section').forEach(section => {
                section.style.display = 'none';
            });
            
            // 显示选中的内容区域
            document.getElementById(contentId).style.display = 'block';
            
            // 更新菜单激活状态
            document.querySelectorAll('.user-menu a').forEach(link => {
                link.classList.remove('active');
            });
            
            // 为当前选中的菜单项添加active类
            const activeLink = document.querySelector(`.user-menu a[onclick="showContent('${contentId}')"]`);
            if (activeLink) {
                activeLink.classList.add('active');
            }
        }

        // 订单筛选功能
        function filterOrders(status) {
            const orderItems = document.querySelectorAll('.order-item');
            const filterBtns = document.querySelectorAll('.filter-btn');
            
            // 更新按钮状态
            filterBtns.forEach(btn => {
                btn.classList.remove('active');
            });
            event.target.classList.add('active');
            
            // 筛选订单
            orderItems.forEach(item => {
                if (status === 'all' || item.getAttribute('data-status') === status) {
                    item.style.display = 'block';
                } else {
                    item.style.display = 'none';
                }
            });
        }

        // 切换设置开关
        function toggleSetting(element) {
            element.classList.toggle('active');
        }

        // 添加新地址
        function addAddress() {
            alert('添加新地址功能');
        }

        // 保存个人资料
        function saveProfile() {
            alert('个人资料已保存');
        }

        // 登录模态框
        function openLoginModal() {
            window.location.href = 'login.html';
        }

        // 退出登录
        function logout() {
            if (confirm('确定要退出登录吗？')) {
                // 清除本地存储
                localStorage.removeItem('isLoggedIn');
                localStorage.removeItem('cartItems');
                
                // 更新登录状态
                updateLoginState();

                alert('已退出登录，购物车和个人中心不可用');
                // 跳转首页
                window.location.href = 'index.html';
            }
        }

        // 自动清缓存（24小时）
        function autoClearCache() {
            const now = Date.now();
            const cacheExpire = 24 * 60 * 60 * 1000; // 缓存有效期：24小时
            const lastClear = parseInt(localStorage.getItem('lastClear')) || 0;

            if (now - lastClear > cacheExpire) {
                console.log('🧹 自动清缓存：超过24小时，清理本地存储数据');
                // 清理购物车、登录状态等
                localStorage.removeItem('cartItems');
                localStorage.removeItem('isLoggedIn');
                localStorage.setItem('lastClear', now);
                // 页面显示更新
                document.querySelector('.cart-count').textContent = 0;
                updateLoginState();
            }
        }

        // 登录/退出状态管理
        function updateLoginState() {
            const isLoggedIn = localStorage.getItem('isLoggedIn') === 'true';
            const loginBtn = document.getElementById('loginBtn');
            const profileBtn = document.getElementById('profileBtn');
            const cartCount = document.querySelector('.cart-count');

            if (isLoggedIn) {
                // 已登录状态：登录按钮不可用且显示"已登录"
                loginBtn.disabled = true;
                loginBtn.classList.add('disabled-btn');
                loginBtn.textContent = '已登录';
                
                // 个人中心按钮可用
                profileBtn.disabled = false;
                profileBtn.classList.remove('disabled-btn');
            } else {
                // 未登录状态：登录按钮可用，个人中心不可用
                loginBtn.disabled = false;
                loginBtn.classList.remove('disabled-btn');
                loginBtn.textContent = '登录';
                
                profileBtn.disabled = true;
                profileBtn.classList.add('disabled-btn');

                // 未登录时清空购物车
                localStorage.removeItem('cartItems');
                if (cartCount) cartCount.textContent = 0;
            }
        }

        // 购物车控制
        function handleCartClick() {
            const isLoggedIn = localStorage.getItem('isLoggedIn') === 'true';
            if (!isLoggedIn) {
                alert('请先登录才能使用购物车');
                window.location.href = 'login.html';
                return;
            }
            // 跳转到购物车页面
            window.location.href = 'cart.html';
        }

        // 个人中心控制
        function handleProfileClick() {
            const isLoggedIn = localStorage.getItem('isLoggedIn') === 'true';
            if (!isLoggedIn) {
                alert('请先登录才能进入个人中心');
                window.location.href = 'login.html';
                return;
            }
            // 已在个人中心页面，无需跳转
        }

        // 页面加载初始化
        window.addEventListener('load', function() {
            // 初始化登录状态
            updateLoginState();
            
            // 初始化购物车数量
            let cartItems = parseInt(localStorage.getItem('cartItems')) || 0;
            document.querySelector('.cart-count').textContent = cartItems;
            
            // 绑定购物车点击事件
            const cartIcon = document.getElementById('cartIcon');
            if (cartIcon) cartIcon.addEventListener('click', handleCartClick);
            
            // 设置自动清缓存
            autoClearCache();
            setInterval(autoClearCache, 60 * 60 * 1000); // 每小时检查一次
        });
    </script>
</body>
</html>
